<%--
  Created by IntelliJ IDEA.
  User: FK
  Date: 2018/1/4
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
        <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

    <html>
    <head>
        <title>环保流程</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8 ? MYOA_CHARSET : htmlspecialchars($HTML_PAGE_CHARSET))?>" />
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="stylesheet" type="text/css" href="/css/street/street.css"/>
        <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
        <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
        <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
        <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
        <%--<link rel="stylesheet" href="/css/officialDocument/rentingList.css">--%>
        <%--<link rel="stylesheet" type="text/css" href="/css/patrol/patrol.css"/>--%>
        <link rel="stylesheet" href="/css/base.css">
        <script src="../js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
        <script src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
        <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
        <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
        <script src="/lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
        <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
        <script src="../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="/js/base/tablePage.js"></script>
        <script src="/lib/laydate/laydate.js"></script>
        <script src="/lib/jquery.form.min.js"></script>
        <style>
            body{
                margin:0px;
            }
            .info{
                width:180px;
                height:28px;
                border-radius: 3px;
                margin-left:20px;
                vertical-align: middle;
            }
            button{
                background: #2f8ae3;
                margin-left: 10px;
                padding: 5px 10px;
                border-radius: 4px;
                color: #fff;
                cursor: pointer;
                font-size:14px;
            }
            #add{
                float:right;
                margin:0px 20px 0px 0px;
            }
            .table{
                width:96%;
                margin:20px auto 0px;
            }
            .tableFoot{
                margin-top:20px;
            }
            .childCheck{
                width:16px;
                vertical-align: middle;
            }
            #checkAll{
                margin-left:10px;
            }
            #outport{
                background: #009900
            }
            #inportEdit{
                background: #009900;
            }
            .M-box3 .active{
                margin: 0px 3px;
                width: 29px;
                height: 29px;
                line-height: 29px;
                background: #2b7fe0;
                font-size: 12px;
                border: 1px solid #2b7fe0;
                color:#fff;
                text-align:center;
                display: inline-block;
            }
            .M-box3 a{
                margin: 0 3px;
                width: 29px;
                height: 29px;
                line-height: 29px;
                font-size: 12px;
                display: inline-block;
                text-align:center;
                background: #fff;
                border: 1px solid #ebebeb;
                color: #bdbdbd;
                text-decoration: none;
            }
            .mainBg .mainTitle{
                min-width: 750px;
            }
            .mainTitleUl .bordercolor span{
                font-size:14px;
            }
            .mainTitleUl .bordercolor label input[type=text]{
                font-size:14px;
            }
            .mainBg{
                padding-top:0px;
            }
            #grid{
                background: none!important;
            }
            .mainTitleUl .bordercolor label{
                text-align: left;
            }
            .mainBg .mainTitle{
                padding:20px 10px 0px;

            }
            .mainTitle{
                min-width: 600px;
            }

            .formUl li input[type=radio]{
                width: 16px;
            }
            .formUl li .radiolabel{
                width: 50px;
            }
            #query_uploadArr{
                margin-top: 5px;
                border: 1px solid #ddd;
                width: 50%;
                float: left;
                min-height: 45px;
                max-height: 102px;
                overflow: auto;
            }
            b {
                color: red;
                display: inline-block;
                vertical-align: middle;
                margin: 5px 5px 0px;
                font-size: 20px;
            }
            .mainTitleUl .bordercolor span{
                left:8px!important;
            }

        </style>
        <link rel="stylesheet" href="/css/biaodan.css">
    </head>
    <body>

    <div class="content" >
        <div style="    height: 45px;border-bottom: 1px solid #dddddd;">
        <div class="headImg" style="    width: 20px;
    height: 20px;
    margin-left: 21px;">
            <img style="    margin-top: 15px;width: 100%;height: 100%" src="/img/document/icon_agentDispatch.png" alt="">
        </div>
        <div class="divTitle" style="    margin-top: -6px;
    font-size: 22px;
    color: #494d59;
    height: 20px;
    margin-left: 50px;
    float: left;">
            环保流程
        </div>
        </div>
        <div style="width:100%;height:calc(100% - 46px)">
            <div style="float:left;width:33%;height:100%;"><img src="../img/map/three.png" style="width:100%;height:100%" alt=""></div>
            <div style="float:left;width:33%;height:100%;"><img src="../img/map/one.png" style="width:100%;height:100%" alt=""></div>
            <div style="float:left;width:33%;height:100%;"><img src="../img/map/two.png" style="width:100%;height:100%" alt=""></div>

        </div>
        <%--<div class="tableList" style="margin-top: 13px;">--%>
            <%--<div class="headNav">--%>
                <%--<input type="text" class="info" placeholder="流程名称">--%>
                <%--&lt;%&ndash;<select class="info" name="xiala" id="">--%>
                    <%--<option value="0">所有处理结果</option>--%>
                    <%--<option value="1">完成</option>--%>
                    <%--<option value="2">未完成</option>--%>
                <%--</select>&ndash;%&gt;--%>
                <%--<button id="query">查询</button>--%>
                <%--&lt;%&ndash;<button id="inport">导入</button>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<button id="inportEdit">导入修改</button>&ndash;%&gt;--%>
                <%--<button class="choose" id="add" data-type="0">新建</button>--%>
            <%--</div>--%>
            <%--<div class="table">--%>
                <%--<table>--%>
                    <%--<thead>--%>
                    <%--<tr>--%>
                        <%--&lt;%&ndash;<th style="width:1%"></th>&ndash;%&gt;--%>
                        <%--<th>序号</th>--%>
                        <%--<th>环保流程名称</th>--%>
                        <%--<th>环保流程类型</th>--%>
                        <%--<th>发布人</th>--%>
                        <%--<th>发布时间</th>--%>
                        <%--&lt;%&ndash;<th>负责人</th>&ndash;%&gt;--%>
                        <%--&lt;%&ndash;<th>负责人联系方式</th>&ndash;%&gt;--%>
                        <%--&lt;%&ndash;<th>卫生许可证</th>&ndash;%&gt;--%>
                        <%--<th>操作</th>--%>
                    <%--</tr>--%>
                    <%--</thead>--%>
                    <%--<tbody class="list">--%>

                    <%--</tbody>--%>
                <%--</table>--%>
                <%--<div class="tableFoot">--%>
                    <%--&lt;%&ndash;<input type="checkbox" id="checkAll"  style="width:16px;vertical-align: middle">&ndash;%&gt;--%>
                    <%--&lt;%&ndash;<label for="checkAll" style="font-size:14px;">全选</label>&ndash;%&gt;--%>
                    <%--&lt;%&ndash;<button id="outport">导出</button>&ndash;%&gt;--%>
                <%--</div>--%>
                <%--<div style="margin: -10px auto 0px;height:50px;width: 97%;" class="clearfix">--%>
                    <%--<div id="dbgz_page" class="M-box3" style="display: none">--%>

                    <%--</div>--%>
                <%--</div>--%>
            <%--</div>--%>
        <%--</div>--%>
        <%--<div class="mainBg" style="display: none">--%>
            <%--<form action="/inspectorProblem/addProblem" id="datasave">--%>
                <%--<input type="file"  onchange="filesTwo(this)" multiple="multiple" name="file" class="picture"--%>
                       <%--style="display: none"/>--%>
                    <%--<input type="hidden" name="attachmentId">--%>
                    <%--<input type="hidden" name="attachmentName">--%>
                    <%--<input type="hidden" name="imageId">--%>
                    <%--<input type="hidden" name="imageName">--%>
                <%--<div class="mainTitle" style="border-bottom: none;">--%>
                    <%--<ul class="mainTitleUl">--%>
                        <%--<li style="    padding-top: 18px;text-align: center;height: 61px;border-bottom: 1px solid #ddd"><span class="spanSize">环保流程</span> </li>--%>
                        <%--<li class="bordercolor clearfix">--%>
                            <%--<span style="border-bottom: 1px solid #fff;"><b>*</b>环保流程名称</span>--%>
                            <%--<label style="width: 80%;">--%>
                                <%--<input type="text" name="flowName" placeholder="请填写环保流程名称" style="background: #fcfcfc;    width: 80%;--%>
    <%--float: none;--%>
    <%--margin-top: 9px;" >--%>
                            <%--</label>--%>
                        <%--</li>--%>
                        <%--<li class="bordercolor clearfix">--%>
                            <%--<span style="border-bottom: 1px solid #fff;">环保流程类型</span>--%>
                            <%--<label style="width: 80%;">--%>
                                <%--<input type="text" name="flowType" placeholder="请填写环保流程类型" style="background: #fcfcfc;    width: 80%;--%>
    <%--float: none;--%>
    <%--margin-top: 9px;">--%>
                            <%--</label>--%>
                        <%--</li>--%>
                        <%--<li class="bordercolor clearfix">--%>
                            <%--<span style="border-bottom: 1px solid #fff;">发布人</span>--%>
                            <%--<label>--%>
                                <%--<input type="text" readonly="readonly" name="reportUser" placeholder="请填写发布人" style="background: #fcfcfc;    width: 75%;--%>
    <%--margin-top: 9px;">--%>
                            <%--</label>--%>
                            <%--<span style="border-bottom: 1px solid #fff;left: -30px!important;">发布时间</span>--%>
                            <%--<label>--%>
                                <%--<input type="text" readonly="readonly" id="times" name="reportTime" placeholder="请填写发布时间" style="background: #fcfcfc;    width: 75%;    margin-left: -56px;--%>
    <%--float: none;--%>
    <%--margin-top: 9px;">--%>
                            <%--</label>--%>
                        <%--</li>--%>
                        <%--<li class="bordercolor clearfix">--%>
                        <%--<span style="border-bottom: 1px solid #fff;height: 78px;--%>
    <%--line-height: 26px;--%>
    <%--padding-top: 24px;    left: 20px;">照片</span>--%>
                            <%--<label style="width: 80%;    height: 100px;">--%>
                                <%--<div class="picture prevTwo" style="position: relative;width: 78%;margin-left: 0;padding-right: 0;">--%>
                                    <%--<input type="hidden" name="attachmentId">--%>
                                    <%--&lt;%&ndash;<a class="fl addPhotos" href="javascript:void (0)" ></a>&ndash;%&gt;--%>
                                    <%--<img class="fl addPhotos" style="    width: 60px;cursor: pointer;height: 60px;margin-top: 4px;margin-right: 7px;display: block;" src="/img/grid/addtupin.png" alt="添加照片">--%>
                                    <%--<input type="hidden" name="attachmentName">--%>

                                    <%--<ul class="fl">--%>
                                        <%--&lt;%&ndash;<li>&ndash;%&gt;--%>
                                        <%--&lt;%&ndash;<img src="/img/app/email.png" alt="">&ndash;%&gt;--%>
                                        <%--&lt;%&ndash;<b class="deleClear">x</b>&ndash;%&gt;--%>
                                        <%--&lt;%&ndash;</li>&ndash;%&gt;--%>
                                    <%--</ul>--%>

                                    <%--&lt;%&ndash;style="display:none;position: absolute;width: 68px;height: 30px;top: 27px;right: 5px;"&ndash;%&gt;--%>

                                <%--</div>--%>
                            <%--</label>--%>
                        <%--</li>--%>
                    <%--</ul>--%>

                <%--</div>--%>
            <%--</form>--%>
            <%--<div style="width:100%;background: #f6f6f6">--%>
                <%--<div class="mainTitle" style="padding:0 10px;border-top:none">--%>
                    <%--<form id="uploadimgform" style="height: 150px;"target="uploadiframe"  action="../upload?module=parameter" enctype="multipart/form-data" method="post">--%>
                        <%--<input type="file" multiple="multiple" name="file" id="uploadinputimg"  class="w-icon5" style="position: absolute;opacity: 0;width: 70px;cursor:pointer;--%>
                        <%--filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0)">--%>
                        <%--<ul class="mainTitleUl"  style="    margin-left: 0px;">--%>
                            <%--<li class="bordercolor clearfix" style="border: none !important;    background: none;">--%>
                                <%--<span style="border-bottom: 1px solid #fff;height: 64px;line-height: 64px">附件</span>--%>
                                <%--<label style="width: 80%;height: 64px;text-align: left;font-size:16px;border-bottom:none;line-height: 20px;">--%>
                                    <%--<div id="query_uploadArr"></div>--%>
                                    <%--<a id="uploadimg" style="cursor: pointer;color:#2F8AE3;padding-left:20px;float:left;line-height: 57px;">附件上传</a>--%>
                                    <%--<div style="width: 400px;">--%>
                                        <%--<a href="javascript:void (0)" data="0" class="preservation" style="--%>
                <%--margin-top: 25px;display: inline-block;margin-right: 10px;--%>
                <%--line-height: 1;font-size:18px;padding: 8px 20px;--%>
                <%--background: #2F8AE3;color: #fff;border-radius: 6px;">保存</a>--%>
                                        <%--<a href="javascript:void (0)" class="getBack"  style="--%>
                <%--margin-top: 25px;display: inline-block;--%>
                <%--line-height: 1;font-size:18px;padding: 8px 20px;background: #2F8AE3;color: #fff;border-radius: 6px" >返回</a>--%>
                                    <%--</div>--%>
                                <%--</label>--%>
                            <%--</li>--%>
                        <%--</ul>--%>
                    <%--</form>--%>
            <%--</div>--%>

        <%--</div>--%>
    <%--</div>--%>
    <script>
        //        附件上传
        $('#uploadimg').click(function(){
            me=this;
            $('#uploadinputimg').click()
        })
        $('#uploadinputimg').fileupload({
            dataType:'json',
            done: function (e, data) {
                if(data.result.obj != ''){
                    var data = data.result.obj;
                    var str = '';
                    var str1 = '';
                    for (var i = 0; i < data.length; i++) {
                        var gs = data[i].attachName.split('.')[1];
                        if(gs == 'jsp'||gs == 'css'||gs == 'js'||gs == 'html'||gs == 'java'||gs == 'php' ){
                            str += '';
                            layer.alert('jsp、css、js、html、java文件禁止上传!',{},function(){
                                layer.closeAll();
                            });
                        }else{
                            str+='<div class="dech" style="margin-left:20px;" deUrl="'+encodeURI(data[i].attUrl)+'" style="display:block;"><a class="ATTACH_a" NAME="'+data[i].attachName+'*" href="<%=basePath %>download?'+encodeURI(data[i].attUrl)+'">'+data[i].attachName+'</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" NAME="'+data[i].attachName+'*"  class="inHidden" value="'+data[i].aid+'@'+data[i].ym+'_'+data[i].attachId+',"></div>';
                        }
                    }
                    $('#query_uploadArr').append(str);
                } else{
                    //alert('添加附件大小不能为空!');
                    layer.alert('添加附件大小不能为空!',{},function(){
                        layer.closeAll();
                    });
                }
            }
        });
        $('#query_uploadArr').on('click','.deImgs',function(){
            var data=$(this).parents('.dech').attr('deUrl');
            var dome=$(this).parents('.dech');
            deleteChatment(data,dome);
        });

        //删除附件
        function deleteChatment(data,element){
            layer.confirm('确定要删除吗？', {<%--确定要删除吗--%>
                btn: ['确定','取消'], //按钮  <%--确定 取消--%>
                title:'删除'  <%--删除附件--%>
            }, function(){
                //确定删除，调接口
                $.ajax({
                    type:'get',
                    url:'../delete',
                    dataType:'json',
                    data:data,
                    success:function(res){

                        if(res.flag == true){
                            layer.msg('删除成功', { icon:6});<%--删除成功--%>
                            element.remove();
                        }else{
                            layer.msg('删除失败', { icon:6});<%--删除失败--%>
                        }
                    }
                });

            }, function(){
                layer.closeAll();
            });
        }

        //    上传图片
        function filesTwo(mes) {
            var arr=mes.files;
            var bool=true;
            for(var i=0;i<arr.length;i++){
                if(arr[i].name.indexOf('.png')==-1&&arr[i].name.indexOf('.jpg')==-1&&arr[i].name.indexOf('.PNG')==-1&&arr[i].name.indexOf('.JPG')==-1){
                    bool=false;
                    break;
                }
            }
            if(!bool){
                $.layerMsg({content:'只能上传.png或.jpg格式！',icon:2});
                return
            }
            $('#datasave').prop('action','/flow/fileUpload?module=parameter')

            $('#datasave').ajaxSubmit({
                type:'post',
                dataType:'json',
                success:function (json) {
                    if(json.flag) {
                        var str='';
                        var arr=json.datas;
                        var attStrId='';
                        var attStrName='';
                        for(var i=0;i<arr.length;i++){

                            str+='<li class="pic" style="padding-left: 0">' +
                                '<img src="/xs?'+arr[i].attUrl+'" alt="">' +
                                '<b class="deleClear">x</b>' +
                                '<input type="hidden" class="hiddenId" value="'+arr[i].attStrId+'">' +//id
                                '<input type="hidden" class="hiddenName" value="'+arr[i].attStrName+'">' +//名字
                                '</li>'
                        }
                        $(me).siblings('ul').append(str)

                    }else {
                        alert('异常')
                    }

                }
            })

        }
        //    点击添加图片
        $('.addPhotos').click(function () {
            me=this;
            $('.picture').click()
        })
        //    点击删除图片
        $(document).delegate('.deleClear','click',function () {
            $(this).parent().remove()
        })


        $(document).on('click','.choose',function(){
            var type=$(this).attr('data-type');
            $('.tableList').hide();
            $('.mainBg').show();
            if(type==0){//新建
                $('.preservation').attr('data-type','0');
                $('.preservation').show();
                use();
                refresh();
                $('.addPhotos').show();
                getUser();
                $('#datasave').attr('action','/environmentflow/addFlow')
            }else if(type==1){//查看
                var id=$(this).parents('tr').attr('id')
                $('.preservation').hide();
                noUser();
                $('.addPhotos').hide();
                detail(id,type)
            }else{//修改
                var id=$(this).parents('tr').attr('id')
                $('.preservation').attr('data-type','2')
                $('.preservation').attr('data-id', id);
                $('.preservation').show();
                $('.addPhotos').show();
                $('#datasave').attr('action','/environmentflow/updateFlowData?flowId='+id)
                use();
                detail(id,type)
            }
        })
        //    点击返回
        $('.getBack').click(function(){
            $('.tableList').show();
            $('.mainBg').hide();
        })
        //    禁用
        function noUser(){
            $('#uploadimg').hide()
            $('input[type="text"]').attr('disabled','disabled');
            $('input[type="radio"]').attr('disabled','disabled');
            $('textarea').attr('disabled','disabled');
            $('select').attr('disabled','disabled');
        }
        //    可以使用
        function use(){
            $('#uploadimg').show()
            $('input[type="text"]').removeAttr('disabled');
            $('input[type="radio"]').removeAttr('disabled');
            $('textarea').removeAttr('disabled');
            $('select').removeAttr('disabled','disabled');
        }
        function getUser(){
            $.ajax({
                url:'/orgGoviment/getSqlType',
                type:'get',
                dataType:'json',
                success:function(res){
                    var data=res.object;
                    $('input[name="reportUser"]').val(data.deptName);
                    //格式化时间
                    var date=new Date();
                    var year=date.getFullYear();
                    var Month=date.getMonth()+1;
                    var days=date.getDate();//获取当前是几号
                    var H=date.getHours();
                    var Min=date.getMinutes();
                    var sec=date.getSeconds();
                    (days>10)?days:days="0"+days;
                    (Month>10)?Month:Month="0"+Month;
                    (H>10)?H:H="0"+H;
                    (Min>10)?Min:Min="0"+Min;
                    (sec>10)?sec:sec="0"+sec;
                    $('input[name="reportTime"]').val(year+'-'+Month+'-'+days+' '+H+':'+Min+':'+sec)

                }
            })
        }
        //    分页列表
        var ajaxPageLe={
            data:{
                page:1,//当前处于第几页
                pageSize:10,//一页显示几条
                useFlag:true
                // computationNumber:null
            },
            page:function () {
                var me=this;
                $.ajax({
                    url:'/environmentflow/getFLowList',
                    type:'get',
                    data:me.data,
                    dataType:'json',
                    success:function(reg){
                        var datas=reg.data;
                        var str="";
                        for(var i=0;i<datas.length;i++){
                            str+=' <tr id="'+datas[i].flowId+'">' +
//                                '                    <td>' +
//                                '                        <input type="checkbox" class="childCheck">' +
//                                '                    </td>' +
                                '                    <td>'+(i+1)+'</td>' +
                                '                    <td>'+'<a href="javascript:;" class="choose" data-type="1">'+datas[i].flowName+'</a>'+'</td>' +
                                '                    <td>'+datas[i].flowType+'</td>' +
                                '                    <td>'+datas[i].reportUser+'</td>' +
                                '                    <td>'+datas[i].reportTime+'</td>' +
                                /*'                    <td>'+datas[i].problemSuituation+'</td>' +
                                '                    <td>'+datas[i].userName+'</td>' +*/
                                    /* '                    <td>'+datas[i].sanitaryPermit+'</td>' +*/
                                '                    <td>' +
//                                '                        <a href="javascript:;" class="choose" data-type="1">查看</a>' +
                                '                        <a href="javascript:;" class="choose" data-type="2">修改</a>' +
                            '                        <a href="javascript:;" class="del">删除</a>' +
                                '                    </td>' +
                                '                </tr>'
                        }
                        $('.list').html(str);
                        if(reg.total>10){
                            $('#dbgz_page').show();
                            me.pageTwo(reg.total,me.data.pageSize,me.data.page)
                        }else{
                            $('#dbgz_page').hide();
                        }

                    }
                })

            },
            pageTwo:function (totalData, pageSize,indexs) {
                var mes=this;
                $('#dbgz_page').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    jump: true,
                    coping: true,
                    homePage:'',
                    endPage: '',
                    current:indexs||1,
                    callback: function (index) {
                        mes.data.page=index.getCurrent();
                        mes.page();
                    }
                });
            }
        }
        ajaxPageLe.page();
        //    点击全选
        $('#checkAll').click(function(){
            var state=$(this).prop('checked');
            if(state == true){
                $(this).prop('checked',true);
                $('.childCheck').prop('checked',true);
            }else{
                $(this).prop('checked',false);
                $('.childCheck').prop('checked',false);
            }
        })
        //    点击删除
        $('.list').on('click','.del',function(){
            var id=$(this).parents('tr').attr('id')
            layer.confirm(' 确定要删除吗', {
                btn: ['确定', '取消'], //按钮
                title: " 删除"
            },function(){
                $.ajax({
                    url:'/environmentflow/deleteFlow',
                    type:'post',
                    dataType:'json',
                    data:{flowId:id},
                    success:function(){
                        layer.msg(' 删除成功', {icon: 6});
                        ajaxPageLe.page();
                    }
                })
            }, function () {
                layer.closeAll();
            })
        })

        //    获取所属社区下拉框内容
        $.get('/code/getCode?parentNo=TYPE_OF_ACCOUNT',function (json) {
            if(json.flag){
                var str='<option value="">请选择</option>';
                for(var i=0;i<json.obj.length;i++){
                    str+='<option value="'+json.obj[i].codeNo+'">'+json.obj[i].codeName+'</option>'
                }
                $('#grid').html(str)
            }
        })

        //    点击保存
        $('.preservation').click(function(){
            var type=$(this).attr('data-type');
            if($('input[name="flowName"]').val()==''){
                $.layerMsg({content:'请填写环保流程名称',icon:7})
                return false
            }
            var fileId="";
            var fileName="";
            for(var i=0;i<$('.inHidden').length;i++){
                fileId += $('.inHidden').eq(i).val();
                fileName += $('.inHidden').eq(i).attr('name');
            }
            $('input[name="attachmentId"]').val(fileId);
            $('input[name="attachmentName"]').val(fileName);

            //图片
            var attIdLen = $('.hiddenId').length;
            var attNameLen = $('.hiddenName').length;
            var attId = "";
            var attName = "";
            for (var i = 0; i < attIdLen; i++) {
                attId += $('.hiddenId').eq(i).attr('value') + ','
            }
            for (var i = 0; i < attNameLen; i++) {
                attName += $('.hiddenName').eq(i).attr('value') + '*'
            }
            $('input[name="imageId"]').val(attId)//图片id
            $('input[name="imageName"]').val(attName)//图片名称
            if(type==0){//新建
                $('#datasave').attr('action','/environmentflow/addFlow')
                $('#datasave').ajaxSubmit({
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        if(res.flag){
                            $.layerMsg({content:'新建成功',icon:1})
                            $('.tableList').show();
                            $('.mainBg').hide();
                            ajaxPageLe.data.page=1;
                            ajaxPageLe.page();
                        }else{
                            $.layerMsg({content:'新建失败',icon:1})
                        }
                    }
                })
            }else if(type==2){
                var id = $(this).attr('data-id')
                $('#datasave').attr('action','/environmentflow/updateFlowData?flowId='+id)
                $('#datasave').ajaxSubmit({

                    type:'post',
                    dataType:'json',
                    success:function(res){
                        if(res.flag){
                            $.layerMsg({content:'修改成功',icon:1})
                            $('.tableList').show();
                            $('.mainBg').hide();
                            ajaxPageLe.data.page=1;
                            ajaxPageLe.page();
                        }else{
                            $.layerMsg({content:'修改失败',icon:1})
                        }
                    }
                })
            }
        })

        $(document).on('click','.pic img',function () {
            var imgg=$(this).get(0)
            var imgs=$(this).attr('src')
            var wt=(document.documentElement.clientWidth || document.body.clientWidth);
            var ht=(document.documentElement.clientHeight || document.body.clientHeight);
            console.log(wt)
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                area:[wt+'px',ht+'px'],
                skin: 'layui-layer-nobg', //没有背景色
                shadeClose: true,
                content:
//                '<img src="'+imgs+'" width="'+wt+'" height="'+ht+'">'
                '<div class="bigImg"  style="width: '+(wt-20)+'px;height:'+ht+'px;text-align: center">' +
                '<img style="margin-top:40px;width:60%;height: 75%;" src="'+imgs+'" style="">' +
                '</div>',
                success:function(){

                }
            });

        })
        $(document).on('click','.layui-layer-nobg',function () {
            layer.closeAll()
        })

        //    查看详情
        function  detail(id,type) {
            $('#query_uploadArr').html('');
            $.ajax({
                url:'/environmentflow/getFlowDataById',
                data:{flowId:id},
                dataType:'json',
                type:'get',
                success:function(res){
                    var data=res.data;
                    var sj =getNowFormatDate(data.reportTime)
                    $('input[name="flowName"]').val(data.flowName);//单位
                    $('input[name="flowType"]').val(data.flowType)//单位地址
                    $('input[name="reportUser"]').val(data.reportUser);//联系人
                    $('input[name="reportTime"]').val(sj);//灶头数


                    //                显示附件
                    var arr = data.attachmentList;
                    var str1=""
                    if (data.attachmentList != '') {
                        for (var i = 0; i < (arr.length); i++) {
                            str1+='<div class="dech" style="margin-left:20px;" deUrl="'+encodeURI(arr[i].attUrl)+'" style="display:block;"><a class="ATTACH_a" NAME="'+arr[i].attachName+'*" href="<%=basePath %>download?'+encodeURI(arr[i].attUrl)+'">'+arr[i].attachName+'</a>'+function(){if(type==1){return ''}else{return '<img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/>'}}()+'<input type="hidden" NAME="'+arr[i].attachName+'*"  class="inHidden" value="'+arr[i].aid+'@'+arr[i].ym+'_'+arr[i].attachId+',"></div>';
                        }
                        $('#query_uploadArr').append(str1);
                    };

                    //                    图片显示
                    var obj=data.imageList;
                    var str2=""
                    for(var i=0;i<obj.length;i++){
                        str2+='<li class="pic"  style="padding-left: 0" >' +
                            '<img src="/xs?'+obj[i].attUrl+'" alt=""  style="cursor:pointer">' +function(){
                                if(type==1){
                                    return ''
                                }else{
                                    return '<b class="deleClear">x</b>';
                                }
                            }()+
                            '<input type="hidden" class="hiddenId"  value="'+obj[i].aid+'@'+obj[i].ym+'_'+obj[i].attachId+'">' +//id
                            '<input type="hidden"  class="hiddenName" value="'+obj[i].attachName+'">' +//名字
                            '</li>'
                    }
                    $('.prevTwo>ul').html(str2);
                    $('input[name="imageId"]').val(data.attachmentId)
                    $('input[name="imageName"]').val(data.attachmentName)
                }
            })
        }

        //    ridio check
        function check(name,data){
            $(':radio[name="'+name+'"][value="'+data+'"]').prop('checked','check')

        }
        //    点击查询
        $('#query').click(function(){
            ajaxPageLe.data.flowName=$('.info').val();
            ajaxPageLe.page();
        })


        function CheckForm(){
            if(document.form1.file.value==""){
                layer.msg("请导入至少一条数据！",{icon:2});
                return (false);
            }
            return (true);
        }

        //    点击导出
        $('#outport').click(function(){
            if($('.childCheck:checked').length<=0){
                $.layerMsg({content:'请选择至少一条数据',icon:6})
            }else{
                var arr=[]
                $('.childCheck:checked').each(function(){
                    var id=$(this).parents('tr').attr('id');
                    arr.push(id)
                })
                var str=arr.join()
                console.log(str)
                window.location.href= '<%=basePath%>inspectorProblem/outPutFile?ids='+str;
            }

        })

        //    重置
        function refresh(){
            $('input[name="flowName"]').val('');//单位
            $('input[name="flowType"]').val('')//单位地址
            $('input[name="reportUser"]').val('');//联系人
            $('input[name="reportTime"]').val('');//灶头数
            $('#query_uploadArr').html('');//备注
            $('.prevTwo>ul').html('');
        }
        function getNowFormatDate(tm) {
            var date = new Date(tm);
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            var Hours = date.getHours();
            var Minutes = date.getMinutes();
            var Seconds = date.getSeconds();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            if (Hours >= 0 && Hours <= 9) {
                Hours = "0" + Hours;
            }
            if (Minutes >= 0 && Minutes <= 9) {
                Minutes = "0" + Minutes;
            }
            if (Seconds >= 0 && Seconds <= 9) {
                Seconds = "0" + Seconds;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
                ' ' + Hours + seperator2 + Minutes +
                seperator2 + Seconds;
            return currentdate;
        }
        var time = {
            elem:'#time',
            format:'YYYY-MM-DD hh:mm:ss',
            min:laydate.now(),
            max:'2999-12-31 23:59:59',
            istime:true,//是否显示时分秒
            istoday:true,//是否显示【今天】的按钮
            isclear:true,//是否显示【清空】的按钮
            festival: true,//是否显示节日
            start: laydate.now(0,"YYYY-MM-DD hh:mm:ss"),  // 开始日期
            fixed: false,   // 是否固定在可视区域
            zIndex: 10000,  // css控制图层的遮罩效果（效果不明显）
            ready: function(dates){  // 选择好日期的回调
                console.log(dates)
            }
        }
        laydate(time);
        $('#time').val(laydate.now(0, 'YYYY-MM-DD hh:mm:ss'));



    </script>
    </body>
    </html>
